package com.wind.taobao.api.trade.trade.convert
{
	import com.wind.taobao.api.trade.trade.model.RefundRemindTimeout;
	import com.wind.taobao.core.util.TaobaoConstants;

	import mx.collections.ArrayCollection;


	/**
	 *  RefundRemindTimeout 转换器
	 * @author fxy
	 *
	 */
	public class RefundRemindTimeoutConvert
	{

		/**
		 * 转换RefundRemindTimeout集合
		 */
		public static function convertRefundRemindTimeouts(value:Object, type:String="json"):ArrayCollection
		{
			var refundRemindTimeouts:ArrayCollection=new ArrayCollection();
			if (value != null)
			{
				if (type == TaobaoConstants.JSON)
				{
					if ((value as Array).length > 0)
					{
						for (var i:uint=0; i < (value as Array).length; i++)
						{
							refundRemindTimeouts.addItem(convertRefundRemindTimeout((value as Array)[i]));
						}
					}
				}
				else
				{
					//TODO
				}
			}
			return refundRemindTimeouts;
		}

		/**
		 * 转换单个RefundRemindTimeout对象
		 * value:XML 或 JSON
		 */
		public static function convertRefundRemindTimeout(value:Object, type:String="json", refundRemindTimeout:RefundRemindTimeout=null):RefundRemindTimeout
		{
			if (refundRemindTimeout == null)
				refundRemindTimeout=new RefundRemindTimeout();
			if (value == null)
				return refundRemindTimeout;
			if (type == TaobaoConstants.XML)
			{
				refundRemindTimeout=convertXMLToRefundRemindTimeout(XML(value), refundRemindTimeout);
			}
			else
			{
				refundRemindTimeout=convertJSONToRefundRemindTimeout(value, refundRemindTimeout);
			}
			return refundRemindTimeout;
		}

		/**
		 * JSON转换为RefundRemindTimeout
		 */
		private static function convertJSONToRefundRemindTimeout(json:Object, refundRemindTimeout:RefundRemindTimeout):RefundRemindTimeout
		{
			if (json.hasOwnProperty(TaobaoConstants.REMIND_TYPE))
			{
				refundRemindTimeout.remind_type=json[TaobaoConstants.REMIND_TYPE];
			}
			if (json.hasOwnProperty(TaobaoConstants.EXIST_TIMEOUT))
			{
				refundRemindTimeout.exist_timeout=json[TaobaoConstants.EXIST_TIMEOUT];//已转换Boolean
			}
			if (json.hasOwnProperty(TaobaoConstants.TIMEOUT))
			{
				refundRemindTimeout.timeout=json[TaobaoConstants.TIMEOUT];
			}
			return refundRemindTimeout;
		}



		/**
		 * XML转换为RefundRemindTimeout
		 */
		private static function convertXMLToRefundRemindTimeout(value:XML, refundRemindTimeout:RefundRemindTimeout):RefundRemindTimeout
		{
			return refundRemindTimeout;
		}



	}
}